<template>
	<view class="layout">
		<view class="navbar">
			<view class="statusBar" :style="{height:getStatusBarHeight()+'px'}"></view>
			<view class="headerBar" :style="{height:getNavigationBarHeight()+'px'}">
				<view class="title">
					{{title}}
				</view>
				<navigator v-if="showSearch" url="/pages/search/search" class="search" >
					<uni-icons type="search"></uni-icons>
					<text class="text">搜索</text>
				</navigator>
			</view>
		</view>
		<view class="fill"  :style="{height:fillHeight}"></view>
	</view>
</template>

<script setup>
	import { getStatusBarHeight, getNavigationBarHeight } from '@/utils/system';
	const props = defineProps({
		title: {
			type: String,
			default: '标题'
		},
		showSearch: {
			type: Boolean,
			default: true
		}
	})
	const fillHeight = computed(()=>{
		return getStatusBarHeight() + getNavigationBarHeight() + 'px';
	})	
</script>

<style lang="scss" scoped>
.layout {
	.navbar {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 999;
		background: linear-gradient(to bottom, transparent, #fff 400rpx),
		linear-gradient(to right, #beecd8 20%,#F4E2D8);
	}
	.headerBar {
		display: flex;
		padding:0 30rpx;
		align-items: center;
		.title {
			font-weight: 700;
			font-size: 22px;
		}
		.search {
			margin-left:30rpx;
			border: 1px solid white;
			border-radius: 60rpx;
			width: 220rpx;
			background: rgba(255,255,255,0.4);
			padding: 5px;
			color:#999;
			font-size: 28rpx;
			.text {
				padding-left:10rpx;
			}
		}
	}
}
</style>